<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //ES6对Number对象的扩展
        //0. Number.EPSILON是JS能表示的最小精度，值约等于2.220446E-16
        console.log(0.1+0.2===0.3) //返回false
        function equal(a,b){
           return Math.abs(a-b)<Number.EPSILON //如果两个数差值小于EPSILON，则认为两数相等
        }
        console.log(equal(0.1+0.2, 0.3)) //返回true
        //1.二进制和八进制
        let b = 0b1010 //二进制
        let o = 0o777 //八进制
        let d = 100 //十进制
        let x = 0xff //16进制
        console.log(b, o, d, x)

        //2.判断一个数是否是有限数
        console.log(Number.isFinite(100)) //T
        console.log(Number.isFinite(100/0)) //F
        console.log(Number.isFinite(Infinity)) //F

        //3.判断一个数是否是NaN
        console.log(Number.isNaN(100)) //F
        console.log(Number.isNaN(NaN)) //T
        console.log(Number.isNaN(Infinity)) //F

        //4.将字符串转为number
        console.log(Number.parseInt('10'))
        console.log(Number.parseFloat('10.23'))

        //5.判断数字是否是整数
        console.log(Number.isInteger(10))
        console.log(Number.isInteger(10.23))

        //6.将数字小数部分抹掉
        console.log(Math.trunc(10))
        console.log(Math.trunc(10.23))
        
        //7.检测一个数的符号
        console.log(Math.sign(10))
        console.log(Math.sign(0))
        console.log(Math.sign(-78))

    </script>
</body>
</html>